package org.smart;

import java.sql.Connection;
import java.sql.SQLException;

public class JDBCTest {
    public static void main(String[] args) {
        JDBC jdbc = new JDBC();
        try {
            Connection connection = jdbc.getConnection();
            if (connection != null && !connection.isClosed()) {
                System.out.println("数据库连接成功！");
                connection.close();
            } else {
                System.out.println("数据库连接失败！");
            }
        } catch (SQLException e) {
            System.out.println("连接数据库时发生错误: " + e.getMessage());
            e.printStackTrace();
        }
    }
}